package in.muton.edushare.pages.cp.courseFBCP;

import in.muton.edushare.pages.common.EdusharePanel;
import in.muton.edushare.pages.cp.CPBase;

import org.apache.wicket.model.IModel;

import com.edushare.common.vo.Poll;
import com.edushare.common.vo.Universities;

/*
 * Course feedback panel has 4 subpanels
 * 1. Shows a list of all current polls(and drafts) and a new poll button.
 * 2. Superpanel that shows the new poll dialog box, adds questions, copies from existing.
 * 3. Last panel that shows the courses, and other options that allow profs to 
 * be added as observers.
 * 
 */

public class CourseFeedbackPage extends CPBase {
	private EdusharePanel activePanel = null;
	private IModel<Poll> activePollModel = null;
	private boolean isParent = true;;

	public static final int SHOW_POLL_LIST = 10;
	public static final int SHOW_POLL_SUBLIST = 20;
	public static final int SHOW_POLL_EDIT = 30;
	public static final int SHOW_POLL_SETTINGS = 40;

	public CourseFeedbackPage(IModel<Universities> univModel) {
		super(univModel, 5);
		setActivePanel(SHOW_POLL_LIST);
	}

	public void setActivePanel(int panelValue) {
		EdusharePanel newPanel = null;
		switch (panelValue) {
		case SHOW_POLL_LIST:
			newPanel = new ListCoursePolls("activePanel", this.univModel, this);
			break;
		case SHOW_POLL_SUBLIST:
			newPanel = new SubListCoursePolls("activePanel", this.univModel,
					this);
			break;
		case SHOW_POLL_EDIT:
			newPanel = new PollCreationPanel("activePanel", this);
			break;
		case SHOW_POLL_SETTINGS:
			newPanel = new PollSettingsPanel("activePanel", this.univModel,
					getActivePollModel(), this, isParent);
			break;
		default:
			break;
		}
		if (activePanel != null && newPanel != null) {
			activePanel.replaceWith(newPanel);
			activePanel = newPanel;
		} else if (newPanel != null) {
			activePanel = newPanel;
			add(activePanel);
		}
	}

	public IModel<Poll> getActivePollModel() {
		return activePollModel;
	}

	public void setActivePollModel(IModel<Poll> activePollModel) {
		this.activePollModel = activePollModel;
	}

	public void setParent(boolean isParent) {
		this.isParent = isParent;
	}

	public boolean isParent() {
		return isParent;
	}

}
